<template>
  <el-container class="main">
    <el-header height="48px" id="header">
      <div class="header-aside border-right text-center">
        <el-image class="header-img" src="https://cdn.hterobot.com/image/xinhuashudianlogo.jpg"
          fit="contain" :style="isCollapse ? 'width:64px; height: 48px' : 'width: 200px; height: 48px'">
          <template #error>
            <div class="image-slot">
              <span v-text="'码客行'"></span>
            </div>
          </template>
        </el-image>
      </div>
      <div class="el-main">
        <el-breadcrumb>
          <el-breadcrumb-item v-for="(v, i) in route.matched" :key="i" :to="{ name: v.name }">{{ v.name
            }}</el-breadcrumb-item>
        </el-breadcrumb>
      </div>
    </el-header>
    <el-container class="context">
      <NavMenu v-bind="{ isCollapse, setisCollapse }"></NavMenu>
      <el-main class="shadow-zdy">
        <router-view v-if="show" class="main-main"></router-view>
      </el-main>
    </el-container>
  </el-container>
</template>

<script setup lang="ts">
import { ElBreadcrumb, ElBreadcrumbItem } from 'element-plus';
import { onMounted, provide, ref } from "vue";
import { useRoute, useRouter } from "vue-router";
import { useStore } from "vuex";
import { Irunactivityoption, Storekey } from "../../interface";
import NavMenu from "../../acCoder/views/NavMenu.vue";
const isCollapse = ref(false)
const show = ref(false)
function setisCollapse(a1: boolean) {
  isCollapse.value = a1
}
const store = useStore(Storekey)
const router = useRouter()
const getrouter = useRoute()

const route = useRoute()

const runactivityoptions = ref<Irunactivityoption[]>([])

provide('runactivityoptions', runactivityoptions)


onMounted(async () => {
  await store.dispatch('actiononline')
  await store.dispatch('actiononline').then(async (e) => {
    if (!e) {
      router.push({
        name: 'Login'
      })
    }
    show.value = true
  })
  store.dispatch('actionlabel')
  store.state.socket.on('activityprocess', (e: Irunactivityoption) => {
    const n = runactivityoptions.value.findIndex(t => t.activityid === e.activityid)
    if (n === -1) {
      runactivityoptions.value.push(e)
    } else {
      runactivityoptions.value[n] = e
    }
  })
})

</script>

<style scoped>
.main {
  height: 100vh;
  width: 100vw;
  overflow: hidden;
}

#header {
  padding: 0;
  display: flex;
  flex-direction: row;
  flex-basis: auto;
  z-index: 3;
}

.header-img {
  scale: 0.7;
  display: flex;
}

.context {
  min-height: 100vh;
  padding-bottom: 48px;
}

#header .el-main {
  padding-bottom: 0;
  box-shadow: 2px 0px 3px 0px #888;
}

#header .el-aside {
  min-width: 48px;
  height: 48px;
  line-height: 48px;
}

.shadow-zdy {
  overflow-y: auto;
  overflow-x: hidden;
  box-shadow: 0px 0px 0px px #888888 inset;
  background-color: #fff;
}

.shadow-zdy::-webkit-scrollbar {
  width: 3px;
  height: 1px;
}

.shadow-zdy::-webkit-scrollbar-thumb {
  border-radius: 3px;
  box-shadow: inset 0 0 5px rgba(0, 0, 255, 0.3);
  background: #535353;
}

.shadow-zdy::-webkit-scrollbar-track {
  box-shadow: inset 0 0 5px rgba(0, 0, 255, 0.3);
  border-radius: 3px;
  background: #ededed;
}

.el-main {
  padding-top: 20px;
  padding-bottom: 0;
}
</style>
